<template>
  <div>
    <UserForm @onSubmit="onSubmit"></UserForm>
  </div>

</template>

<script>
import { loginAPI } from '../api/loginapi'
import UserForm from '../components/userForm.vue'
import { setToken } from '../router/storage'

export default {
  name: 'LoginPage',
  components: {
    UserForm
  },
  methods: {
    async onSubmit (values) {
      const res = await loginAPI(values)
      console.log('res --->', res)
      this.$toast('登陆成功')
      setToken(res.token)
      this.$router.push('/article')
    }
  }
}
</script>
